#pragma once
#include "generator-support.h"

namespace cccn
{
namespace internal
{

/**
 * The class finds a minimum circuit from a given node v.
 * The global minimum circuit can be found by applying
 * the same calculation on all nodes
 *
 * The speed of finding the global minimum circuit can be
 * shorten by not re-applying NodeMinCircuit on nodes
 * that are already seen in a previous application of NodeMinCircuit.
 *
 * To enable this speed improvement, NodeMinCircuit maintains
 * all then nodes on the found minimum circuit.
 */ 
class NodeMinCircuitFinder
  {
  private:
    typedef boost::graph_traits<BoostGraph_t>::vertex_descriptor Vertex_t;
  public:
    /**
     * Start finding the minimum circuit on the graph g
     * that passes through the vertex v
     *
     * \param v_id id of the vertex v
     * \param g the graph on which a minimum circuit passing through v is found
     */
    NodeMinCircuitFinder (uint v_id, const Graph& g);
    /**
     * \return the length of the minimum circuit passes through the node v
     */
    uint GetLength () const;
    /**
     * \return a list of nodes on the found minimum circuit passing through the node v
     */
    list<uint> GetCircuit () const;

  private:
    /**
     * Start finding the minimum circuit passing through the node v
     */
    void Find (uint v, const Graph& g);

    const Graph& m_graph;
    /// the node from which a minimum circuit is found
    const uint m_v;

    /// contain the list of nodes on the minimum circuit passing through the node v
    list<uint> m_minCircuit;
  };

} // namespace internal
} // namespace cccn